package it.unibz.easytravel.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DatabaseHelper extends SQLiteOpenHelper {
	
	private static final String TAG = "DatabaseHelper";
	
	private static final String DATABASE_NAME = "easytravel";

	private static final int DATABASE_VERSION = 35;


	DatabaseHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	
	@Override
	public void onCreate(SQLiteDatabase db) {
		CommonItemsDbAdapter.onCreate(db);
		DebtsDbAdapter.onCreate(db);
		ExpensesDbAdapter.onCreate(db);
		PersonalItemsDbAdapter.onCreate(db);
		LocationDbAdapter.onCreate(db);
		SelectPersonalItemsDbAdapter.onCreate(db);
		PlacemarkDbAdapter.onCreate(db);
		PersonDbAdapter.onCreate(db);
		TravelDbAdapter.onCreate(db);
		TravellersDbAdapter.onCreate(db);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
				+ newVersion + ", which will destroy all old data");
		CommonItemsDbAdapter.onUpgrade(db);
		DebtsDbAdapter.onUpgrade(db);
		ExpensesDbAdapter.onUpgrade(db);
		PersonalItemsDbAdapter.onUpgrade(db);
		LocationDbAdapter.onUpgrade(db);
		SelectPersonalItemsDbAdapter.onUpgrade(db);
		PlacemarkDbAdapter.onUpgrade(db);
		PersonDbAdapter.onUpgrade(db);
		TravelDbAdapter.onUpgrade(db);
		TravellersDbAdapter.onUpgrade(db);
	}
}